      SUBROUTINE XC_NORME
     &          (za,ze)

c***********************************************************************
c                         subroutine xc_norme
c***********************************************************************

c  Program Source:  Naval Ocean Systems Center - Code 542

c  Date:
c     10 Apr 1990

c  Function:
c     Takes the extended complex number:
c         z=za*exp(ze)
c     and returns a "normalized" extended complex number such that
c         exp(-1).le.max(ABS(real(za)),ABS(imag(za)))
c     and
c         max(ABS(real(za)),ABS(imag(za))).le.exp(+1)
c     and
c         ze has integer values

c  Parameters passed:
c     za             [c] complex amplitude of z
c     ze             [r] real exponent     of z

c  Parameters returned:
c     za             [c] complex amplitude of z
c     ze             [r] real exponent     of z

c  Common blocks referenced:

c  Functions and subroutines referenced:
c     dabs
c     dfloat
c     dimag
c     dmax1
c     dreal
c     idint

c  References:

c  Change History:

c*******************!***************************************************

      implicit real*8 (a-h,o-z)

      parameter    (jmax=88)

      complex  * 16 za

c     EP is an array containing values of exp(+j) for j=0 to jmax
c     EM is an array containing values of exp(-j) for j=0 to jmax

c     NOTE: exp(+jmax) is the largest integer power of exp(1)
c           that does not overflow; exp(-jmax) is the largest
c           integer power of exp(-1) that does not underflow

      dimension     ep(0:jmax),em(0:jmax)

      data ep/
     &  .100000000000000d+01,.271828182845905d+01,.738905609893065d+01,
     &  .200855369231877d+02,.545981500331442d+02,.148413159102577d+03,
     &  .403428793492735d+03,.109663315842846d+04,.298095798704173d+04,
     &  .810308392757538d+04,.220264657948067d+05,.598741417151978d+05,
     &  .162754791419004d+06,.442413392008921d+06,.120260428416478d+07,
     &  .326901737247211d+07,.888611052050787d+07,.241549527535753d+08,
     &  .656599691373305d+08,.178482300963187d+09,.485165195409790d+09,
     &  .131881573448321d+10,.358491284613159d+10,.974480344624890d+10,
     &  .264891221298435d+11,.720048993373859d+11,.195729609428839d+12,
     &  .532048240601799d+12,.144625706429148d+13,.393133429714404d+13,
     &  .106864745815245d+14,.290488496652474d+14,.789629601826807d+14,
     &  .214643579785916d+15,.583461742527455d+15,.158601345231343d+16,
     &  .431123154711520d+16,.117191423728026d+17,.318559317571138d+17,
     &  .865934004239937d+17,.235385266837020d+18,.639843493530055d+18,
     &  .173927494152050d+19,.472783946822935d+19,.128516001143593d+20,
     &  .349342710574851d+20,.949611942060245d+20,.258131288619007d+21,
     &  .701673591209763d+21,.190734657249510d+22,.518470552858707d+22,
     &  .140934908242694d+23,.383100800071658d+23,.104137594330291d+24,
     &  .283075330327469d+24,.769478526514202d+24,.209165949601300d+25,
     &  .568571999933593d+25,.154553893559010d+26,.420121040379051d+26,
     &  .114200738981568d+27,.310429793570192d+27,.843835666874145d+27,
     &  .229378315946961d+28,.623514908081162d+28,.169488924441033d+29,
     &  .460718663433129d+29,.125236317084221d+30,.340427604993174d+30,
     &  .925378172558779d+30,.251543867091917d+31,.683767122976274d+31,
     &  .185867174528413d+32,.505239363027610d+32,.137338297954018d+33,
     &  .373324199679900d+33,.101480038811389d+34,.275851345452317d+34,
     &  .749841699699012d+34,.203828106651267d+35,.554062238439351d+35,
     &  .150609731458503d+36,.409399696212745d+36,.111286375479176d+37,
     &  .302507732220114d+37,.822301271462291d+37,.223524660373472d+38,
     &  .607603022505687d+38,.165163625499400d+39/
      data em/
     &  .100000000000000d+01,.367879441171442d+00,.135335283236613d+00,
     &  .497870683678639d-01,.183156388887342d-01,.673794699908547d-02,
     &  .247875217666636d-02,.911881965554516d-03,.335462627902512d-03,
     &  .123409804086680d-03,.453999297624849d-04,.167017007902457d-04,
     &  .614421235332821d-05,.226032940698105d-05,.831528719103568d-06,
     &  .305902320501826d-06,.112535174719259d-06,.413993771878517d-07,
     &  .152299797447126d-07,.560279643753727d-08,.206115362243856d-08,
     &  .758256042791191d-09,.278946809286892d-09,.102618796317019d-09,
     &  .377513454427910d-10,.138879438649640d-10,.510908902806332d-11,
     &  .187952881653908d-11,.691440010694020d-12,.254366564737692d-12,
     &  .935762296884017d-13,.344247710846998d-13,.126641655490942d-13,
     &  .465888614510340d-14,.171390843154201d-14,.630511676014699d-15,
     &  .231952283024357d-15,.853304762574407d-16,.313913279204803d-16,
     &  .115482241730158d-16,.424835425529159d-17,.156288218933499d-17,
     &  .574952226429356d-18,.211513103759108d-18,.778113224113380d-19,
     &  .286251858054939d-19,.105306173575538d-19,.387399762868719d-20,
     &  .142516408274094d-20,.524288566336346d-21,.192874984796392d-21,
     &  .709547416228470d-22,.261027906966770d-22,.960268005450868d-23,
     &  .353262857220081d-23,.129958142500750d-23,.478089288388547d-24,
     &  .175879220242431d-24,.647023492564546d-25,.238026640869440d-25,
     &  .875651076269652d-26,.322134028599252d-26,.118506486423398d-26,
     &  .435961000006308d-27,.160381089054864d-27,.590009054159706d-28,
     &  .217052201130364d-28,.798490424568698d-29,.293748211171080d-29,
     &  .108063927770728d-29,.397544973590865d-30,.146248622725123d-30,
     &  .538018616002114d-31,.197925987794690d-31,.728129017832164d-32,
     &  .267863696180808d-32,.985415468611126d-33,.362514091914356d-33,
     &  .133361481550226d-33,.490609473064928d-34,.180485138784542d-34,
     &  .663967719958073d-35,.244260073774053d-35,.898582594404938d-36,
     &  .330570062676073d-36,.121609929925283d-36,.447377930618112d-37,
     &  .164581143108227d-37,.605460189540119d-38/


      ize=IDINT(ze)
      tze=DFLOAT(ize)
      fze=ze-tze
      ze=tze
      if (fze .ne. 0.0d0) za=za*DEXP(fze)

      x=DREAL(za)
      xabs=DABS(x)
      y=DIMAG(za)
      yABS=DABS(y)
      xymax=DMAX1(xabs,yabs)

      if (xymax .ge. 1.0d0) then
         do 100 j=1,jmax
            if (xymax .lt. ep(j)) then
               ze=ze+DFLOAT(j-1)
               za=za*em(j-1)
               RETURN
            end if
100      continue

      else
         do 110 j=1,jmax
            if (xymax .gt. em(j)) then
               ze=ze-DFLOAT(j-1)
               za=za*ep(j-1)
               RETURN
            end if
110      continue
      end if

      END      ! XC_NORME
